{extend name='admin@main'}

{block name="content"}
<form onsubmit="return false;" id="MemberForm" data-auto="true" method="post" class='layui-form layui-card'
      autocomplete="off">

    <div class="layui-card-body">
        {notempty name='vo.id'}
        <div class="layui-form-item">
            <label class="layui-form-label">会员ID</label>
            <div class="layui-input-block">
                <input disabled value='{$vo.id}' class="layui-input layui-bg-gray">
            </div>
        </div>
        {/notempty}

        <div class="layui-form-item">
            <label class="layui-form-label">会员账号</label>
            <div class="layui-input-block">
                {if isset($vo) and isset($vo.account)}
                <input disabled value='{$vo.account|default=""}' class="layui-input layui-bg-gray">
                {else}
                <input name="account" value='{$vo.account|default=""}' required pattern="^.{4,}$"
                       placeholder="请输入4位及以上字符登录用户账号" class="layui-input">
                {/if}
                <p class="help-block">用户账号创建后，不允许再次修改。</p>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">会员昵称</label>
                <div class="layui-input-block">
                    <input name="nickname" required value='{$vo.nickname|default=""}' placeholder="请输入会员昵称"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">真实姓名</label>
                <div class="layui-input-block">
                    <input name="realname" value='{$vo.realname|default=""}' placeholder="请输入真实姓名"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">

                <label class="layui-form-label">会员头像</label>
                <div class="layui-input-block">
                    <input name="avatar" type="hidden" value="{$vo.avatar|default=''}">
                </div>
                <script>$('[name="avatar"]').uploadOneImage()</script>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">推广员ID</label>
                <div class="layui-input-block">
                    <input name="parent_id" value='{$vo.parent_id|default="0"}' placeholder="请输入推广员ID"
                           class="layui-input">
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label">手机号码</label>
                <div class="layui-input-block">
                    <input name="phone" value='{$vo.phone|default=""}' placeholder="请输入手机号码"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">备用号码</label>
                <div class="layui-input-block">
                    <input name="spare_phone" value='{$vo.spare_phone|default=""}' placeholder="请输入备用号码"
                           class="layui-input">
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label">会员等级</label>
                <div class="layui-input-block">
                    <select class="layui-select" required name="level" lay-search>
                        {foreach $level_list as $level}
                        {if isset($vo.level) and $vo.level eq $level.level}
                        <option selected value="{$level.level}">{$level.level} - {$level.levelname|default='默认等级'}
                        </option>
                        {else}
                        <option value="{$level.level}">{$level.level} - {$level.levelname|default='默认等级'}</option>
                        {/if}
                        {/foreach}
                    </select>
                </div>

            </div>

            <div class="layui-form-item">

                <label class="layui-form-label">会员状态</label>
                <div class="layui-input-block">
                    {php}isset($vo['status']) or $vo['status']=1;{/php}
                    {foreach ['1' => '启用','0' => '停用'] as $k => $v}
                    <!--{eq name='vo.status' value='$k'}-->
                    <label class="think-radio">
                        <input type="radio" value="{$k}" name="status" title="{$v}" checked lay-ignore> {$v}</label>
                    <!--{else}-->
                    <label class="think-radio"><input type="radio" value="{$k}" name="status" title="{$v}" lay-ignore>
                        {$v}</label>
                    <!--{/eq}-->
                    {/foreach}

                </div>
            </div>

            <div class="layui-form-item">

                <label class="layui-form-label">推广权限</label>
                <div class="layui-input-block">
                    {php}isset($vo['is_agent']) or $vo['is_agent']=0;{/php}
                    {foreach ['1' => '启用','0' => '停用'] as $k => $v}
                    <!--{eq name='vo.is_agent' value='$k'}-->
                    <label class="think-radio">
                        <input type="radio" value="{$k}" name="is_agent" title="{$v}" checked lay-ignore> {$v}</label>
                    <!--{else}-->
                    <label class="think-radio"><input type="radio" value="{$k}" name="is_agent" title="{$v}" lay-ignore>
                        {$v}</label>
                    <!--{/eq}-->
                    {/foreach}

                </div>
            </div>
            {notempty name='vo.id'}
            <div class="layui-form-item">
                <label class="layui-form-label">会员积分</label>
                <div class="layui-input-block">
                    <div class="layui-input-inline">
                        <input disabled value='{$vo.credit1}' class="layui-input layui-bg-gray">
                    </div>
                    <button type='button' class='layui-btn layui-btn-primary'
                            data-modal='{:url("recharge")}?type=credit1&id={$vo.id}'>充值积分
                    </button>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">会员余额</label>
                <div class="layui-input-block">
                    <div class="layui-input-inline">
                        <input disabled value='{$vo.credit2}' class="layui-input layui-bg-gray">
                        <!-- </div>
                        <button  type='button' class='layui-btn layui-btn-primary'>充值余额</button> -->
                    </div>
                </div>
            </div>
            {/notempty}
            <div class="hr-line-dashed"></div>

            <div class="layui-form-item text-center">
                {notempty name='vo.id'}<input type="hidden" name="id" value="{$vo.id}">{/notempty}
                <button class="layui-btn" type='submit'>保存数据</button>
                <button class="layui-btn layui-btn-danger" ng-click="hsitoryBack()" type="button">取消编辑</button>
            </div>

</form>
{/block}

{block name='script'}
<script>
    window.form.render();
    require(['angular'], function () {
        var app = angular.module("MemberForm", []).run(callback);
        angular.bootstrap(document.getElementById(app.name), [app.name]);

        function callback($rootScope) {
            //$rootScope.isAddMode = parseInt('{$isAddMode|default=0}');
            // 返回会员列表
            $rootScope.hsitoryBack = function () {
                $.msg.confirm('确定要取消编辑吗？', function (index) {
                    history.back(), $.msg.close(index);
                });
            };
        }
    });
</script>
{/block}